Skip to content

reduce allocations in GetExt#1045

Merged
egibs merged 3 commits into
chainguard-dev:mainfrom
Ritish134:main
Jul 16, 2025
Merged

reduce allocations in GetExt#1045
egibs merged 3 commits into
chainguard-dev:mainfrom
Ritish134:main

Conversation

@Ritish134

Copy link
Copy Markdown
Contributor

Reduce allocations in GetExt

This change optimizes the GetExt function by replacing strings.Split and fmt.Sprintf with simpler index lookups and string slicing.
This results in fewer heap allocations (allocs/op) when scanning large sets of files and slightly better performance.


Benchmark before:

Benchmark Before

Benchmark after:

Benchmark After

@egibs egibs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I wasn't a huge fan of my original implementation and this is much better.

@egibs egibs merged commit 9354797 into chainguard-dev:main Jul 16, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants